package com.genesis.yunnanji.activity;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.Toolbar;
import android.view.View;

import com.genesis.yunnanji.R;
import com.genesis.yunnanji.adapter.TabAdapter;
import com.genesis.yunnanji.fragment.Comment;

import org.xutils.view.annotation.ViewInject;

import java.util.ArrayList;
import java.util.List;



public class MyComment extends BaseActivity {
    @ViewInject(R.id.tl_comment_tab)
    private TabLayout mTablayout;
    @ViewInject(R.id.vp_comment_viewpager)
    private ViewPager mViewPager;
    @ViewInject(R.id.tb_comment_toolbar)
    private Toolbar mToolbar;
    private TabAdapter adapter;
    public String[] tabTitle;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState, R.layout.activity_mycomment);
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        mToolbar.setTitle("");
        setSupportActionBar(mToolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    @Override
    protected void setUpView() {
        tabTitle = new String[]{"我的评论", "回复我的"};
        mTablayout.setTabMode(TabLayout.MODE_FIXED);
        mTablayout.setTabGravity(TabLayout.GRAVITY_FILL);
        List<Fragment> fragments = new ArrayList<>();
        fragments.add(Comment.newInstance(1));
        fragments.add(Comment.newInstance(2));
        adapter = new TabAdapter(getSupportFragmentManager(), fragments, tabTitle);

        mViewPager.setAdapter(adapter);
        mTablayout.setupWithViewPager(mViewPager);
    }
}
